package com.zrrd.mcl.webll.controller;

import com.zrrd.mcl.model.order.OrderInfo;
import com.zrrd.mcl.order.client.OrderFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
public class PaymentController {

    @Autowired
    private OrderFeignClient orderFeignClient;

    @GetMapping("/pay.html")
    public String pay(HttpServletRequest request) {
        //获取地址中传来的订单ID
        String orderId = request.getParameter("orderId");
        //通过feign请求访问订单服务  获取订单信息
        OrderInfo orderInfo = orderFeignClient.getOrderInfo(Long.parseLong(orderId));
        System.out.println("订单信息为==========>" + orderInfo);
        //存入请求中
        request.setAttribute("orderInfo", orderInfo);
        //跳转到支付下单页面
        return "payment/pay";
    }
}
